// pages/client_follow/client_follow.js
// import {createSelectorQuery} from "./index";

let listBehavior = require('../../behavior/list'),
  $util = wx.$util,
  {windowHeight} = wx.getSystemInfoSync();
Page({
  behaviors: [ listBehavior, ],

  /**
   * 页面的初始数据
   */
  data: {
    buttons:[
      // {label: '点赞',id: '',icon: 'icon-dianzan',badge: 100},
      // {label: '关注',id: '',icon: 'icon-guanzhu',badge: 100},
      // {label: '提醒',id: '',icon: 'icon-tixing',badge: 100},
      {label: '回复',id: '$reply',icon: 'icon-huifu',badge: 'followup_reply_total',active: false},
    ],
    approveFlag: false,
    replyFlag: false,
    list: [],

    //搜索
    searchList: [
      {field_id: 'is_see_atme',type: 'picklist',field_name: '@我的',optionList: [{label: '已查看',id: true},{label: '未查看',badge: 0,id: false}],optionId: 'id'},
      {field_id: 'my_send',type: 'picklist',field_name: '我发出的',optionList: [{label: '跟踪',id: 'is_my_followup'},{label: '回复',id: 'is_my_reply'},{label: '审批', id: 'is_my_approval'}],optionId: 'id'},
      {field_id: 'my_approve',type: 'picklist',field_name: '审批',optionList: [{label: '待处理',id: 'is_pending'},{label: '已处理',id: 'is_processed'},{label: '抄送我',id: 'is_cc'}],optionId: 'id'},
      {field_id: 'followup_type_row_id',type: 'reference',field_name: '跟踪类型',optionList: [],optionId: 'row_id',optionName: 'followup_type_alias'},
      {field_id: 'followup_progress_row_id',type: 'reference',field_name: '进度',optionList: [],optionId: 'row_id',optionName: 'followup_progress_alias'},
      {field_id: 'followup_tag_row_id',type: 'reference1',field_name: '标签',optionList: [],optionId: 'row_id',optionName: 'followup_tag_name'},
      {field_id: 'date',type: 'datetime',field_name: '时间',dateList: [{id: 'today',name: '今天'},{id: 'week',name: '本周'},{id: 'month',name: '本月'}]},
      {field_id: 'followup_department_row_id',type: 'reference1',field_name: '部门',optionList: [],optionId: 'id',optionName: 'name'},
      {field_id: 'followup_user_row_id',type: 'reference1',field_name: '人员',optionList: [],optionId: 'id',optionName: 'name'},
    ],

    //用户列表
    fieldList: [
      {field_id: 'user_list',type: 'picklist',showFlag: false, optionList: [],optionId: 'id',optionName: 'name'},
    ]
  },
  //点击底部按钮
  async bindButton(e){
    let {id, index, new_approve} = e.currentTarget.dataset,
      {list} = this.data,
      field = id + '_active',
      data = list[index];

    if (id === '$reply') {
      data.$approve_active = false;
      if (!data.$reply_list) {
        await this.getReplyList(data.row_id).then(res=>{
          data.$reply_list = res;
        })
      }
    }
    if (id === '$approve') {
      if (new_approve){
        wx.navigateTo({
          url: `/DIYPages/client_follow_update/client_follow_update?status=edit&rid=${data.row_id}`
        });
        return
      }
      data.$reply_active = false;
    }

    data[field] = !data[field];
    this.setData({
      [`list[${index}]`]: data
    });
  },

  //搜索
  searchComb(e){

    let {iptVal,quick} = e.detail,
      post = {};
    iptVal && (post.followup_content = iptVal);
    quick.forEach(item=>{
      let {CompareValue,CompareWith,Operator} = item;
      CompareWith = CompareWith.split('.');
      CompareWith = CompareWith[1] ? CompareWith[1] : CompareWith;
      //@我的
      if (CompareWith === 'is_see_atme') post.is_see_atme = CompareValue;
      //我发出的、审批
      if (['my_send','my_approve'].includes(CompareWith)) post[CompareValue] = true;
      //跟踪类型、进度、标签
      if (['followup_type_row_id','followup_progress_row_id','followup_tag_row_id','followup_department_row_id','followup_user_row_id'].includes(CompareWith)) post[CompareWith] = CompareValue;
      //日期时间
      if (CompareWith === 'date') {
        //今天
        if (CompareValue === 'today'){
          let date = $util.formatDate(new Date(),'yyyy-MM-dd');
          post.date_s = date;
          post.date_e = date;
        }
        //本周
        else if (CompareValue === 'week'){
          post.date_s = $util.getWeekFirstLastDate('s');
          post.date_e = $util.getWeekFirstLastDate('e');

        }
        //本月
        else if (CompareValue === 'month'){
          post.date_s = $util.formatDate($util.getMonthFirstDate(),'yyyy-MM-dd');
          post.date_e = $util.formatDate($util.getMonthLastDate(),'yyyy-MM-dd');

        } else if (Operator === '>=') {
          post.date_s = CompareValue;
        } else if (Operator === '<=') {
          post.date_e = CompareValue;
        }
      }
    });
    this.data.where = post;
    this.getFirstPage();
  },

  //获取跟进内容列表
  getData(post){
    let url = 'AllFollowup/query_all_followup';
    return new Promise(resolve => {

      wx.$post(1,url,post).then(res=>{
        let total = 0,
          list = this.data.list,
          obj = {};

        if (res.data.row && res.data.row.length){
          total = res.data.total;
          let rows = res.data.row;
          rows.map(async (item,i)=>{
            //图片
            if (item.followup_image_json){
              item.followup_image_json = JSON.parse(item.followup_image_json);
            }
            //附件
            if (item.followup_file_json){
              item.followup_file_json = JSON.parse(item.followup_file_json);
            }
            //内容
            let content = item.followup_content,
              reg1 = /\<div(.+?)\<\/div\>/g,
              reg2 = /\<(.+?)\>/g,
              str = content.replace(reg1,'');  //替换网页端格式的html代码
            str = str.replace(reg2,'');
            item.followup_content = str;

            let self = wx.getStorageSync('user_id')
            //@本人
            if (item.followup_at_json){
              let followup_at_json = JSON.parse(item.followup_at_json);
              let isAtMe = false;
              isAtMe = followup_at_json.user.some(function (ite) {
                return ite.id == self;
              });
              item.$is_at_me = isAtMe;
            }
            //本人录入
            let isSelf = item.input_id == self;
            item.$is_self = isSelf;

            await this.getApprovalProcess(item.row_id).then((res)=>{
              item.$approve_list = res.data; //审批列表
              item.$approve_active = !!res.data; //审批按钮显示状态
              item.$approve_new_submit = !res.data || (!['已同意','已提交','已重新提交','待审'].includes(res.state));  //审批是否未提交
              item.$approve_state = '同意'; //审批提交状态-默认值
              item.$approve_input = '同意'; //审批提交内容-默认值
              item.$is_cc_me = res.$is_cc_me;
              res.data && (item.$approve_process = res.data[0].process_id); //审批号
            });

            //循环结束
            if (i === rows.length-1) {
              obj = {total,rows};
              resolve(obj);
            }
          });
        }else {
          resolve({total,rows: []});
        }
      });
    })
  },
  getDataList(){
    let url = 'AllFollowup/query_all_followup',
      {where,page,limit} = this.data,
      post = {"row_id": 0, page , limit, ...where};
    this.getData(post).then(res=>{
      let {total,rows} = res,
        obj = {};
      if(page !== 1 && rows.length) rows = [ ...list,...rows, ];
      obj = {total,list: rows,page};
      console.log(obj);
      this.setData(obj);
    })
    /*wx.$post(1,url,post).then(res=>{
      let total = 0,
        list = this.data.list,
        obj = {};

      if (res.data.row){
        total = res.data.total;
        let rows = res.data.row;
        rows.map(async (item,i)=>{
          //图片
          if (item.followup_image_json){
            item.followup_image_json = JSON.parse(item.followup_image_json);
          }
          //附件
          if (item.followup_file_json){
            item.followup_file_json = JSON.parse(item.followup_file_json);
          }
          //内容
          let content = item.followup_content,
            reg1 = /\<div(.+?)\<\/div\>/g,
            reg2 = /\<(.+?)\>/g,
            str = content.replace(reg1,'');  //替换网页端格式的html代码
          str = str.replace(reg2,'');
          item.followup_content = str;

          let self = wx.getStorageSync('user_id')
          //@本人
          if (item.followup_at_json){
            let followup_at_json = JSON.parse(item.followup_at_json);
            let isAtMe = false;
            isAtMe = followup_at_json.user.some(function (ite) {
              return ite.id == self;
            });
            item.$is_at_me = isAtMe;
          }
          //本人录入
          let isSelf = item.input_id == self;
          item.$is_self = isSelf;

          await this.getApprovalProcess(item.row_id).then(res=>{
            item.$approve_list = res; //审批列表
            item.$approve_active = !!res; //审批按钮显示状态
            item.$approve_new_submit = !res;  //审批是否未提交
            item.$approve_state = '同意'; //审批提交状态-默认值
            item.$approve_input = '同意'; //审批提交内容-默认值
            res && (item.$approve_process = res[0].process_id); //审批号
          });

          //循环结束
          if (i === rows.length-1) {
            if(page !== 1) rows = [ ...list,...rows, ];
            obj = {total,list: rows,page};
            this.setData(obj);
          }
        });
      }else {
        this.setData(obj);
      }

    })*/
  },
  //预览图片
  previewImg(e){
    let {src,index} = e.currentTarget.dataset,
      {list} = this.data;
    wx.previewImage({
      current: src,
      urls: list[index].followup_image_json
    })
  },
  //删除跟进
  deleteFollow(e){
    let {index} = e.currentTarget.dataset,
      {list} = this.data;
    let url = 'AllFollowup/delete_all_followup',
      post = {row_id: list[index].row_id};

    wx.showModal({
      title: '提示',
      content: '确定删除该跟进？',
      success: (res) => {
        if(res.confirm) {
          wx.showLoading({mask: true});
          wx.$post(1,url,post).then(res=>{
            if (res.errcode != 0)return;
            wx.$toast('删除成功！');
            list.splice(index,1);
            this.setData({list});
          })
        }
      },
    })
  },
  //跳转页面
  navTo(e){
    let {url,index} = e.currentTarget.dataset;
    this.data.editIndex = index;
    wx.navigateTo({url});
  },
  //新增编辑后刷新页面数据
  refreshData(status){
    let {editIndex,list } = this.data;
    if (status === 'edit'){
      let post = {"row_id": list[editIndex].row_id, page: 1 , limit: 1};
      this.getData(post).then(res=>{
        this.setData({
          [`list[${editIndex}]`]: res.rows[0]
        })
      });
    } else {
      this.getFirstPage();
    }
  },

  //获取审批内容
  getApprovalProcess(id){
    return new Promise(resolve => {
      let url = 'Approval_process/query_approval_process_log_group',
        post = {
          "page": 1,
          "limit": 1000,
          "oby": "input_time,step,log_row_id",
          "SearchWhere": [
            {
              "CompareWith": "table_id",
              "Operator": "=",
              "CompareValue": "all_followup",
              "or": 0
            },
            {
              "CompareWith": "row_id",
              "Operator": "=",
              "CompareValue": id,
              "or": 0
            },
            /*{
              "CompareWith": "1",
              "Operator": "=",
              "CompareValue": "(CASE WHEN step>1 AND sh_state='待审' THEN 0 ELSE 1 END)",
              "or": 0
            }*/
          ]
        };
      wx.$post(3,url,post).then(res=>{
        if (res.errcode != 0)return;
        let self = wx.getStorageSync('user_id')
        let row = res.data.row || [],
          lastGroup = row[row.length - 1 ],
          data = lastGroup && lastGroup.process;
        //有数-已提交
        if (lastGroup && data && data.length){
          let $is_cc_me = lastGroup.cc_ed_state === '已抄送' && lastGroup.cc.some(item=>{
            return item.user_id == self && !item.is_check
          })
          resolve({data,state: lastGroup.process_ed_state,$is_cc_me})
        }
        //无数-未提交
        else{
          resolve({data: ''});
        }
      })
    })
  },
  //切换审批状态
  approveState(e){
    let {type,index} = e.currentTarget.dataset,
      {list} = this.data,
      data = list[index];
    data.$approve_state = type;
    data.$approve_input = type;
    this.setData({
      [`list[${index}]`]: data
    })
  },
  //输入审批内容
  approveInput(e){
    let {index} = e.currentTarget.dataset,
      {list} = this.data,
      value = e.detail.value;

    this.setData({
      [` list[${index}].$approve_input`]: value
    });
  },
  //发送审批
  approveSend(e){
    let {index} = e.currentTarget.dataset,
      {list} = this.data,
      data = list[index];
    this.submitApprove(data).then((res)=>{
      data.$approve_list = res.data; //审批列表
      data.$approve_active = !!res.data; //审批按钮显示状态
      data.$approve_new_submit = !res.data || (!['已同意','已提交','已重新提交','待审'].includes(res.state));  //审批是否未提交
      data.$approve_state = '同意'; //审批提交状态-默认值
      data.$approve_input = '同意'; //审批提交内容-默认值
      data.$is_cc_me = res.$is_cc_me;
      res.data && (data.$approve_process = res.data[0].process_id); //审批号
      data.is_approval_process_self = res.is_operate;
      this.setData({
        [`list[${index}]`]: data
      });
    })
  },
  submitApprove(data){
    let { $approve_process,$approve_input,$approve_state,row_id} = data,
      post = {
        "table_id": 'all_followup',
        "row_id": row_id ,
        "sh_state": $approve_state,
        "next_sh_id":"",
        "next_sh_name":"",
        "sh_mark": $approve_input || "",
        "process_id": $approve_process
      };
    return new Promise(resolve => {
      wx.$post(3,'Approval_process/update_approval_process_log',post).then(async res=>{
        if (res.errcode != 0) return;
        let list = [],state,$is_cc_me;
        await this.getApprovalProcess(row_id).then((res)=>{
          list = res.data;
          state = res.state;
          $is_cc_me = res.$is_cc_me;
        });
        let is_operate = await this.isApprovalUser(row_id);
        resolve({data:list,state,is_operate,$is_cc_me});
        this.getFollowStateTotal();
      });
    });

  },
  //获取当前人员是否可操作审批
  async isApprovalUser (rowid){ //是否可修改字段，修改字段
    let post = {
        "table_id": 'all_followup',
        "row_id": rowid
      },
      is_operate = false;
    await wx.$post(3,'Approval_process/get_approval_process_operate',post).then(res=>{
      if (res.errcode != 0)return;
      let data = res.data.row || [],
        is_operate = data[0] && data[0].is_operate;
    });
    return is_operate;
  },

  //获取回复列表
  getReplyList(id){
    let url = 'AllFollowup/query_all_followup_reply',
      post = {
        "parent_row_id": id,
        "row_id": 0,
        "page": 1,
        "limit": 0
      };
    return new Promise(resolve => {
      wx.$post(1,url,post).then(res=>{
        if (res.errcode != 0)return;
        let list = res.data.row || [],
          self = wx.getStorageSync('user_id'),
          isAtMe = false;
        list.map(item=>{
          let content = item.reply_content,
            reg1 = /\<div(.+?)\<\/div\>/g,
            reg2 = /\<(.+?)\>/g,
            str = content.replace(reg1,'');  //替换网页端格式的html代码
          str = str.replace(reg2,'');
          item.reply_content = str;
          let followup_at_json = item.followup_at_json && JSON.parse(item.followup_at_json);
          followup_at_json && (isAtMe = followup_at_json.user.some(function (ite) {
            return ite.id == self;
          }));
        });
        //@本人更新
        if (isAtMe){
          this.updateFollowState(id,'reply')
        }
        resolve(list);
      })
    })
  },
  //输入回复内容
  replyInput(e){
    let {index} = e.currentTarget.dataset,
      {list, fieldList} = this.data,
      value = e.detail.value,
      $reply_input = list[index].$reply_input || '',
      last = value.substring($reply_input.length);
    if (last === '@'){
      wx.hideKeyboard();
      fieldList[0].showFlag = !fieldList[0].showFlag;
      fieldList[0].followIndex = index;
      this.setData({fieldList})
    }else {

      this.setData({
        [`list[${index}].$reply_input`]: value
      })
    }
  },
  //选择@用户
  selectUser({detail}){
    let {fieldList,list} = this.data,
      {followIndex} = fieldList[0],
      data = list[followIndex],
      {$reply_at_user, $reply_input} = data;
    $reply_at_user = $reply_at_user || [];
    let isexist = $reply_at_user.some(item=>{
      item.id === detail.id
    });
    if (!isexist) {
      $reply_at_user.push(detail);
    }
    $reply_input += '@'+ detail.name;
    data.$reply_input = $reply_input;
    data.$reply_at_user = $reply_at_user;
    data.$reply_input_focus = true;
    this.setData({
      [`list[${followIndex}]`]: data
    })
  },
  //发送回复
  replySend(e){
    let {index} = e.currentTarget.dataset,
      {list} = this.data,
      data = list[index];
    this.submitReply(data).then(res=>{
      data.$reply_list = res;
      data.$reply_input = ''; //清空回复输入框
      data.$reply_at_user = []; //清空回复@人
      data.$reply_row_id = 0; //回复行id清0
      this.setData({
        [`list[${index}]`]: data
      })
    })
  },
  submitReply(data){
    let url = 'AllFollowup/update_all_followup_reply',
      datetime = wx.$util.formatDate(new Date()),
      post = {
        "parent_row_id": data.row_id,
        "row_id": data.$reply_row_id || 0,
        "reply_datetime": datetime,
        "reply_content": data.$reply_input,
        "followup_at_json": data.$reply_at_user && data.$reply_at_user.length ? data.$reply_at_user : null,
      };
    return new Promise(resolve => {
      wx.showLoading({mask: true});
      wx.$post(1,url,post).then(res=>{
        if (res.errcode != 0)return;
        wx.$toast('发送成功！');
        this.getReplyList(data.row_id).then(res=>{
          resolve(res)
        })
      })
    })
  },
  //删除回复
  deleteReply(e){
    let {f_index,r_index,rid} = e.currentTarget.dataset,
      url = 'AllFollowup/delete_all_followup_reply',
      post = {row_id: rid},
      {list} = this.data,
      data = list[f_index],
      {$reply_list} = data;
    wx.showModal({
      title: '提示',
      content: '确定删除该回复？',
      success: (res) => {
        if(res.confirm) {
          wx.showLoading({mask: true});
          wx.$post(1,url,post).then(res=>{
            if (res.errcode != 0)return;
            wx.$toast('删除成功！');
            $reply_list.splice(r_index,1);
            this.setData({
              [`list[${f_index}]`]: data
            });
          })
        }
      },
    })
  },
  //编辑回复
  editReply(e){
    let {f_index,r_index,rid} = e.currentTarget.dataset,
      {list } = this.data,
      data= list[f_index],
      { $reply_list} = data;
    data.$reply_input = $reply_list[r_index].reply_content;
    data.$reply_row_id = rid;
    this.setData({
      [`list[${f_index}]`]: data
    });

  },
  //取消编辑回复
  cancelReply(e){
    let {f_index,r_index,rid} = e.currentTarget.dataset,
      {list } = this.data,
      data= list[f_index];
    data.$reply_input = '';
    data.$reply_row_id = 0;
    this.setData({
      [`list[${f_index}]`]: data
    });
  },

  //获取选项
  getOptionsList(arg){
    let [key,v,url,post,method] = arg;
    return new Promise((resolve,reject) => {
      if (method === 'get'){
        wx.$get(v,url).then(res=>{
          if (res.errcode != 0){
            reject();
            return;
          }
          let data = res.data.row || [],
            list = data;
          resolve({[key]: list});

        });
        return;
      }
      wx.$post(v, url, post).then(res=>{
        if (res.errcode != 0){
          reject();
          return;
        }
        let data = res.data.row || [],
          list = data;
        resolve({[key]: list});
      });
    });

  },

  ready(){
    let parmaArr = [
        ['followup_type_row_id',1,'AllFollowup/query_all_followup_type',{"row_id": 0},'post'],  //类别
        ['followup_progress_row_id',1,'AllFollowup/query_all_followup_progress',{"row_id": 0},'post'],  //进度
        ['followup_tag_row_id',1,'AllFollowup/query_all_followup_tag',{"row_id": 0},'post'],  //标签
        ['followup_user_row_id',3,'BaseTable/select_user',{},'get'],  //用户
        ['followup_department_row_id',3,'BaseTable/select_department',{},'get'],  //部门
        ['state_total',1,'AllFollowup/get_all_followup_state_total',{},'post'],  //状态统计
      ],
      pmArr = [];
    wx.$each(parmaArr,(i,item)=>{
      pmArr.push(this.getOptionsList(item));
    });
    Promise.all(pmArr.map(p => p.catch(err => ''))).then(res=>{
      let resObj = {};

      wx.$each(res,(i,item)=>{
        resObj = {...resObj,...item}
      });
      let searchList = this.data.searchList;
      wx.$each(searchList,(i,item)=>{
        if (resObj[item.field_id]){
          item.optionList = resObj[item.field_id];
        }
      });
      let state_total = resObj.state_total[0];
      searchList[0].optionList[1].badge = state_total.at_not_see_totle
      searchList[2].optionList[0].badge = state_total.pending_totle
      searchList[2].optionList[2].badge = state_total.cc_totle;

      this.setData({
        searchList,
        ['fieldList[0].optionList']: resObj.followup_user_row_id
      });

    });
  },

  //滚动结束
  onDragEnd(e){
    let query = wx.createSelectorQuery()
    query.selectAll('.is_at_me').boundingClientRect();
    query.selectAll('.is_cc_me').boundingClientRect();

    query.exec(rect=>{
      let [is_at_me,is_cc_me] = rect,
        {list} = this.data,
        pmArr = [],
        updateData = [];

      is_at_me.forEach(item=>{
        let { top ,height, dataset} = item,
          data = list[dataset.index];
        if ((top < windowHeight) && (top + height -88 > 0)){
          console.log('跟进@在可视区域');
          pmArr.push(this.updateFollowState(data.row_id,'follow'));
          updateData.push({index: dataset.index,field : '$is_at_me'});
        }
      });
      is_cc_me.forEach(item=>{
        let { top ,height, dataset} = item,
          data = list[dataset.index];
        if ((top < windowHeight) && (top + height -88 > 0)){
          console.log('审批抄送在可视区域')
          pmArr.push(this.updateFollowState(data.row_id,'cc'));
          updateData.push({index: dataset.index,field : '$is_cc_me'});
        }
      });
      pmArr.length && Promise.all(pmArr.map(p => p.catch(err => ''))).then(res=>{
        this.getFollowStateTotal();
        let obj = {};
        //更新数据状态
        updateData.forEach(item=>{
          obj[`list[${item.index}].${item.field}`] = false;
        });
        this.setData(obj)
      })
    })
  },
  //更新@本人
  updateFollowState(id,type){//  type：reply回复@，follow跟进@ ，cc审批抄送
    let url = 'AllFollowup/update_all_followup_at_see',
      post = {row_id: id},
      v = 1;
    if(type === 'reply'){
      url = 'AllFollowup/update_all_followup_reply_at_see'
    }
    if (type === 'cc') {
      url = 'Approval_process/update_approval_cc';
      v = 3;
      post.table_id = 'all_followup';
    }
    return new Promise(resolve => {
      wx.$post(v,url,post).then(res=>{
        if (res.errcode != 0)return;
        resolve(type);
      })
    })
  },
  getFollowStateTotal(){
    this.getOptionsList(['state_total',1,'AllFollowup/get_all_followup_state_total',{},'post']).then(res=>{
      let data = res.state_total[0];
      this.setData({
        ['searchList[0].optionList[1].badge']: data.at_not_see_totle,
        ['searchList[2].optionList[0].badge']: data.pending_totle,
        ['searchList[2].optionList[2].badge']: data.cc_totle
      });
    })
  },

  //更新抄送
  updateApprovalCC(id){
    let url = 'Approval_process/update_approval_cc',
      post = {
        "table_id": "all_followup",
        "row_id": id,
      };
    return new Promise(resolve => {
      wx.$post(3,url,post).then(res=>{
        if (res.errcode != 0)return;
        resolve();
      })
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // wx.$setBarTitle();
    wx.$getAuth('all_followup').then(res=>{
      if (!res.tableSee) {
        wx.$toast('抱歉，您没有权限查看该模块数据！',1000).then(()=>{
          wx.navigateBack({ delta:1 });
        });
        return
      }
      this.setData({
        auth: res
      });
      this.getDataList();

      this.ready();
    });


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})
